package edu.nynu.cityeasy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * 积分流水明细表
 * @TableName points_ledger
 */
@TableName(value ="points_ledger")
@Data
public class PointsLedger implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 积分账户ID (关联 user_points_account.id)
     */
    private Long accountId;

    /**
     * 操作人ID (哪个用户触发的, 关联 user_account.id)
     */
    private Long userId;

    /**
     * 积分变动数 (正数为获取, 负数为消耗)
     */
    private Integer amount;

    /**
     * 变动后总积分 (用于审计)
     */
    private Integer balanceAfter;

    /**
     * 流水类型: 获取, 消耗, 过期
     */
    private Object type;

    /**
     * 积分变动描述 (如 "每日登录", "兑换:10kg大米")
     */
    private String description;

    /**
     * 关联业务类型 (如 "WORK_ORDER", "REDEMPTION_ORDER")
     */
    private String relatedEntityType;

    /**
     * 关联业务ID (如 工单ID, 兑换订单ID)
     */
    private Long relatedEntityId;

    /**
     * 关联房屋ID (如在A房屋报修, 关联 unit.id)
     */
    private Long unitId;

    /**
     * 
     */
    private Date createdAt;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        PointsLedger other = (PointsLedger) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getAccountId() == null ? other.getAccountId() == null : this.getAccountId().equals(other.getAccountId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
            && (this.getBalanceAfter() == null ? other.getBalanceAfter() == null : this.getBalanceAfter().equals(other.getBalanceAfter()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
            && (this.getRelatedEntityType() == null ? other.getRelatedEntityType() == null : this.getRelatedEntityType().equals(other.getRelatedEntityType()))
            && (this.getRelatedEntityId() == null ? other.getRelatedEntityId() == null : this.getRelatedEntityId().equals(other.getRelatedEntityId()))
            && (this.getUnitId() == null ? other.getUnitId() == null : this.getUnitId().equals(other.getUnitId()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getAccountId() == null) ? 0 : getAccountId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
        result = prime * result + ((getBalanceAfter() == null) ? 0 : getBalanceAfter().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getRelatedEntityType() == null) ? 0 : getRelatedEntityType().hashCode());
        result = prime * result + ((getRelatedEntityId() == null) ? 0 : getRelatedEntityId().hashCode());
        result = prime * result + ((getUnitId() == null) ? 0 : getUnitId().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", accountId=").append(accountId);
        sb.append(", userId=").append(userId);
        sb.append(", amount=").append(amount);
        sb.append(", balanceAfter=").append(balanceAfter);
        sb.append(", type=").append(type);
        sb.append(", description=").append(description);
        sb.append(", relatedEntityType=").append(relatedEntityType);
        sb.append(", relatedEntityId=").append(relatedEntityId);
        sb.append(", unitId=").append(unitId);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}